﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using LIM.forms.uc_SYS_QuanTriNguoiDung;

using LIM.controller;
using LIM.model;
using Telerik.WinControls.UI;
using System.Threading;

namespace LIM.forms
{
    public partial class radForm_SYS_CauHinhKetNoi : RadForm
    {
        public radForm_SYS_CauHinhKetNoi()
        {
            InitializeComponent();

            RefreshData();
        }


        public void RefreshData()
        {
            this.radTextBox_DatabaseConnectionString.Text = "";
            this.radTextBox_FTPServer.Text = "";
            this.radTextBox_FTPUsername.Text = "";
            this.radTextBox_FTPPassword.Text = "";
            this.radTextBox_AllowUsers.Text = cls_Registry.Get_AllowUsers();
        }

        private void radMenuItem_Refresh_Click(object sender, EventArgs e)
        {
            RefreshData();
        }

        private void linkLabel_MakeTemplate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.radTextBox_DatabaseConnectionString.Text = "data source=projects.3psolutions.com.vn,1434;initial catalog=EDC-LIMS-2013-01-15;user id=lims;password=123qwe!@#;multipleactiveresultsets=True;App=EntityFramework";
        }

        private void radMenuItem_Save_Click(object sender, EventArgs e)
        {
            try
            {
                cls_Registry.Save_DatabaseConnectionString(this.radTextBox_DatabaseConnectionString.Text.Trim());
                cls_Registry.Save_FTPConnection(this.radTextBox_FTPServer.Text.Trim(), this.radTextBox_FTPUsername.Text.Trim(), this.radTextBox_FTPPassword.Text.Trim());
                cls_Registry.Save_AllowUsers(this.radTextBox_AllowUsers.Text.Trim());
                MessageBox.Show("Đã lưu thành công");
            }
            catch (Exception ex)
            {                
            }
        }
        
    }
}
